#include <iostream>
#include <string>
#include <memory.h>
using namespace std;

typedef int State[52];
string s, t;

inline 
int hash_trans(char ch) {
	if (ch >= 'a' && ch <= 'z') return ch - 'a';
    return ch - 'A' + 26;
}

inline 
void hash_to(string x, State &time) {
	memset(time, 0, sizeof(time));
	for (unsigned i = 0; i < x.size(); ++i) {
		++time[hash_trans(x[i])];
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> t >> s;
	State th;
	hash_to(t, th);
	State xx;
	hash_to(s.substr(0, t.size()), xx);
	int ans = 0;
	for (unsigned k = 1; k <= s.size() - t.size(); ++k) {
		if (memcmp(xx, th, sizeof(xx)) == 0) ++ans;
		--xx[hash_trans(s[k-1])];
		++xx[hash_trans(s[k+t.size()-1])];
	}
	if (memcmp(xx, th, sizeof(xx)) == 0) ++ans;

	cout << ans << endl;
	return 0;
}